<?php if (!defined('THINK_PATH')) exit();?>
<form actions='/index.php/User/User/pwd_set_c' method='post'>
	<div style='display:flex;margin-top:16px'>
		<div style='flex:3;text-align:right'> 原密码：</div>		
		<div style='flex:7'>
			<input type='password' name='ChangePwd_Pwd' style='width:70%' />
		</div>
	</div>

	<div style='display:flex;margin-top:16px'>
		<div style='flex:3;text-align:right'> 新密码：</div>		
		<div style='flex:7'>
			<input type='password' name='ChangePwd_PwdN' style='width:70%' />
		</div>
	</div>

	<div style='display:flex;margin-top:16px'>
		<div style='flex:3;text-align:right'> 确认密码：</div>		
		<div style='flex:7'>
			<input type='password' name='ChangePwd_PwdN2' style='width:70%' />
		</div>
	</div>

	<div style='margin-top:15px;text-align:center'>
		<button type='button' id='ChangePwd_sub'>修改</button>
		<input type='reset' value='重置' />	
	</div>
</form>
<script>
	$('#ChangePwd_sub').click(function(){
		var pwd = $('input[name=ChangePwd_Pwd]').val();
		var pwd_n = $('input[name=ChangePwd_PwdN]').val();
		var pwd_n2 = $('input[name=ChangePwd_PwdN2]').val();
		if(!pwd || !pwd_n || !pwd_n2){
			alert('密码项不得为空！');exit;
		}
		if(pwd_n != pwd_n2){
			alert('新密码不一致！');exit;
		}
		if(pwd == pwd_n){
			alert('新旧密码不得相同！');exit;
		}
		$.ajax({
			url:'/index.php/User/User/pwd_change_ajax',
			type:'post',
			data:{
				token:'<?php echo Token_Set('pwd_change_ajax');?>',
				pwd:pwd,
				pwd_n:pwd_n,
				pwd_n2:pwd_n2
			},
			success:function(res){
				//alert(res);
				switch(res){
					case 'e1':
						alert('信息填写不完整！');
						flashpage();
					break;
					case 'e2':
						alert('原密码不正确！');
						flashpage();
					break;
					case 'e3':
						alert('两次新密码不一致！');
						flashpage();
					break;
					case 'e4':
						alert('新旧密码不得相同！');
						flashpage();
					break;
					case 'e5':
						alert('密码修改失败！');
						flashpage();
					break;
					case 'ok':
						alert('密码修改成功！');
						flashpage();
					break;
					default:
						alert('非法访问！');
						flashpage();
				}
			}
		});
	});
	function flashpage(){
		$('#Me_Info').css('background','#eee');
		$('#Me_ChangePwd').css('background','blue');
		$.ajax({
			url:'/index.php/User/User/change_pwd',
			success:function(res){
				$('#Me_Main').html(res);
				sessionStorage.ChangePwd=escape(res);
			}
		});
	}
</script>